<?php


// no direct access
defined('_JEXEC') or die ('Restricted access');

class JElementComponent extends JElement {
	var	$_name = 'component';
	function fetchElement($name, $value, &$node, $control_name) {
		$db = &JFactory::getDBO();
		$query = 'SELECT c.id, c.name, c.link, c.option' .
				' FROM #__components AS c' .
				' WHERE c.link <> "" AND parent = 0' .
				' ORDER BY c.name';
		$db->setQuery( $query );
		$mitems = $db->loadObjectList();
		foreach ( $mitems as $item ) {
			$components[] = JHTML::_('select.option',  $item->link, $item->name );
		}
		
		$output= JHTML::_('select.genericlist',  $components, ''.$control_name.'['.$name.']', 'class="inputbox"', 'value', 'text', $value );
		
		return $output;
	}
	
	
}